package com.cqeec.myblog.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.cqeec.myblog.model.Photo;
import com.cqeec.myblog.util.DbUtil;

public class PhotoDaoImpl implements PhotoDao {

	@Override
	public void save(Photo photo) throws ClassNotFoundException, SQLException {
		Connection conn = DbUtil.getDbConnection();
		PreparedStatement ps = conn.prepareStatement("INSERT INTO Photo VALUES(?,?,?,?)");
		ps.setString(1, photo.getId());
		ps.setString(2, photo.getAlbum());
		ps.setString(3, photo.getName());
		ps.setDate(4, new java.sql.Date(photo.getUploadTime().getTime()));
		ps.executeUpdate();
		ps.close();
	}

}
